import sys
if __name__ == '__main__':
    money = 1000
    print("商品列表")
    shopList = [['小米手机',500],['华为手机',300],['vivo手机',100]]
    for i in range(len(shopList)):
        print(shopList[i])
    shoppingCart = []
    print("商品编号")
    for j in range(len(shopList)):
        print(j, shopList[j])
    while True:
        print("添加购物车")
        num = str(input("请输入您要购买的商品编号，输入'q'退岀选择:"))
        if num.isdigit():
            if 0 <= int(num) < len(shopList):
                if money > 0:
                    shoppingCart.append(shopList[int(num)])
                    b = shopList[int(num)]
                    price = b[1]
                    print("商品添加成功")
                    money = money - price
                    print("恭喜，购买成功！您的卡余额还剩:"+str(money))
                else:
                    print("穷鬼，钱不够！请到其他超市购买！")
            else:
                print("没有这个商品，别瞎弄！")
        elif num == 'q':
            print("查看购物车")
            for i in range(len(shoppingCart)):
                print(shoppingCart[i])
            break
        else:
            print("请输入正确的操作")